package com.ruoyi.web.controller.combat.useralignment;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.combat.domain.userlocation.CombatRelation;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.combat.domain.useralignment.CombatRelationWb;
import com.ruoyi.combat.service.useralignment.ICombatRelationWbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课题五微博用户社交关系
Controller
 * 
 * @author ruoyi
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/combat/relationWb")
public class CombatRelationWbController extends BaseController
{
    @Autowired
    private ICombatRelationWbService combatRelationWbService;

    /**
     * 查询课题五微博用户社交关系
列表
     */
    @PreAuthorize("@ss.hasPermi('combat:relationWb:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatRelationWb combatRelationWb)
    {
        startPage();
        List<CombatRelationWb> list = combatRelationWbService.selectCombatRelationWbList(combatRelationWb);
        return getDataTable(list);
    }

    /**
     * 导出课题五微博用户社交关系
列表
     */
    @PreAuthorize("@ss.hasPermi('combat:relationWb:export')")
    @Log(title = "课题五微博用户社交关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatRelationWb combatRelationWb)
    {
        List<CombatRelationWb> list = combatRelationWbService.selectCombatRelationWbList(combatRelationWb);
        ExcelUtil<CombatRelationWb> util = new ExcelUtil<CombatRelationWb>(CombatRelationWb.class);
        util.exportExcel(response, list, "课题五微博用户社交关系数据");
    }

    /**
     * 获取课题五微博用户社交关系
详细信息
     */
    @PreAuthorize("@ss.hasPermi('combat:relationWb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatRelationWbService.selectCombatRelationWbById(id));
    }

    /**
     * 新增课题五微博用户社交关系

     */
    @PreAuthorize("@ss.hasPermi('combat:relationWb:add')")
    @Log(title = "课题五微博用户社交关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CombatRelationWb combatRelationWb)
    {
        return toAjax(combatRelationWbService.insertCombatRelationWb(combatRelationWb));
    }

    /**
     * 修改课题五微博用户社交关系

     */
    @PreAuthorize("@ss.hasPermi('combat:relationWb:edit')")
    @Log(title = "课题五微博用户社交关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CombatRelationWb combatRelationWb)
    {
        return toAjax(combatRelationWbService.updateCombatRelationWb(combatRelationWb));
    }

    /**
     * 删除课题五微博用户社交关系

     */
    @PreAuthorize("@ss.hasPermi('combat:relationWb:remove')")
    @Log(title = "课题五微博用户社交关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatRelationWbService.deleteCombatRelationWbByIds(ids));
    }

    /**
     * 查询用户的关注/粉丝
     */
    @ApiOperation(value = "查询用户社交关系列表")
    @PreAuthorize("@ss.hasPermi('system:relation:list')")
    @GetMapping("/user/{userId}")
    public TableDataInfo list(@PathVariable String userId, @RequestParam(required = false) String plate,
                              @RequestParam(required = false) String relation) {
        startPage();
//        CombatRelation combatRelation = new CombatRelation(null, userId, null, relation, null, plate);
        List<CombatRelationWb> list = combatRelationWbService.selectRelationByUserId(userId);
        return getDataTable(list);
    }
}
